<template>
  <section>
    <div v-if="orderDefaults && labelValue">
      {{ labelValue}}
    </div>
    <div v-else-if="label==='TransportTags'">
      <el-tag v-for="item in TransportTags"
              :key="item.label"
              effect="plain"
              style="margin-right:5px">
        {{ item.label }}
      </el-tag>
    </div>
    <div v-else>
      --
    </div>
  </section>
</template>

<script>
export default {
  name: "CustomerOrderConfig",
  props: {
    orderDefaults: {
      type: Object,
      default: () => { }
    },
    label: {
      type: String,
      default: null
    }
  },
  computed: {
    labelValue () {
      if (this.label === 'insure') {
        return this.orderDefaults[this.label] ? '是' : '否'
      }
      return this.orderDefaults[this.label]
    },
    tags () {
      return [
        { name: 'pick', label: '提' },
        { name: 'deliver', label: '送' },
        { name: 'onLoad', label: '装' },
        { name: 'offLoad', label: '卸' },
      ];
    },
    TransportTags () {
      let arr = [];
      this.tags.map(item => {
        if (this.orderDefaults?.[item.name]) {
          arr.push({ label: item.label })
        }
      })
      return arr;
    }
  }
};
</script>
